﻿#ifndef MEASUREALGORITHM_H
#define MEASUREALGORITHM_H
#include <QPointF>
#include <QRect>
#include <QVector>

namespace Qly
{
class CircleMeasure
{
public:

    bool buildBy3Points(QPointF p1, QPointF p2, QPointF p3);
    bool buildBy3Points(QPoint p1, QPoint p2, QPoint p3);
    bool buildByCentreRadius(QPointF centre, double radius);
    bool buildByCentrePoint(QPointF centre, QPointF p);
    bool buildByDiameterPoints(QPointF p1, QPointF p2);
    QPointF m_centre; // 圆心
    double m_radius; // 半径
    QPointF m_points[3]; // 三点圆的三个点，对于其他类型这个数组里面的无效
    QRectF m_rectangle;
    double m_theta[3]; // 三个点的角度值，单位弧度
    double m_det_theta[2]; // 第二个点到第一个点的夹角，第三个点到第一个点的夹角
    int m_rotateDir; // 1 表示逆时针转，-1 表示顺时针转
};

/**
 * @brief The PolygonMeasure class 多边形相关的算法
 * 暂时只实现了面积。后面还会加重心、转动惯量等参数
 */
class PolygonMeasure
{
public:
    bool buildByPoints(QVector<QPointF> p);
    bool buildByPoints(QVector<QPoint> p);
    QVector<QPointF> m_points;
    double m_area; // 多边形的面积
private:
    bool computeArea();
};


class AngleMeasure
{
public:
    bool buildBy3Points(QPointF p1, QPointF p2, QPointF p3);
    bool buildBy3Points(QPoint p1, QPoint p2, QPoint p3);
    QPointF m_points[3];
    double m_theta; // 夹角，单位弧度
    double m_degree; //夹角，单位度
};

} //namespace Qly
#endif // MEASUREALGORITHM_H
